package com.tiantang.kafka.interceptor;

import java.util.Map;

import org.apache.kafka.clients.producer.ProducerInterceptor;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;

/**
 * 
 * @description:功能描述 Kafka生产者拦截器，在消息发送时给消息加上时间戳
 * @author: liujinkun
 * @date 2018年5月27日
 * @version:1.0
 */
public class TimeInterceptor implements ProducerInterceptor<String, String> {

	public void configure(Map<String, ?> configs) {

	}

	public ProducerRecord<String, String> onSend(ProducerRecord<String, String> record) {
		return new ProducerRecord<String, String>(record.topic(), record.partition(), record.key(),
				System.currentTimeMillis() + "**" + record.value());
	}

	public void onAcknowledgement(RecordMetadata metadata, Exception exception) {

	}

	public void close() {

	}

}
